﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChinaDynastyTours.Controls;
using IToursDataService.Models;

namespace ChinaDynastyTours.Helpers
{
    public static class EnumHelper
    {
        #region 团状态枚举帮助
        /// <summary>
        /// String型转成团状态枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static TeamStateEnum Team_Str2Enum(string name, bool igonreCase)
        {
            return (TeamStateEnum)Enum.Parse(typeof(TeamStateEnum), name, igonreCase);
        }
        /// <summary>
        /// 团状态枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int Team_Enum2Int(TeamStateEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成对应团状态枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static TeamStateEnum Team_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(TeamStateEnum), n))
                return (TeamStateEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 团状态枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Team_Enum2Str(TeamStateEnum type)
        {
            return type.ToString();
        } 
        #endregion

        #region 费用所属类型枚举帮助
        /// <summary>
        /// String型转成费用所属类型枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static ProviderTypeEnum TypeBelong_Str2Enum(string name, bool igonreCase)
        {
            return (ProviderTypeEnum)Enum.Parse(typeof(ProviderTypeEnum), name, igonreCase);
        }
        /// <summary>
        /// 费用所属类型枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int TypeBelong_Enum2Int(ProviderTypeEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成对应费用所属类型枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static ProviderTypeEnum TypeBelong_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(ProviderTypeEnum), n))
                return (ProviderTypeEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 费用所属类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string TypeBelong_Enum2Str(ProviderTypeEnum type)
        {
            return type.ToString();
        }
        #endregion

        #region 交通工具类型枚举帮助
        /// <summary>
        /// String型转成交通工具类型枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static TrafficTypeEnum Traffic_Str2Enum(string name, bool igonreCase)
        {
            return (TrafficTypeEnum)Enum.Parse(typeof(TrafficTypeEnum), name, igonreCase);
        }
        /// <summary>
        /// 交通工具类型枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int Traffic_Enum2Int(TrafficTypeEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成对应交通工具类型枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static TrafficTypeEnum Traffic_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(TrafficTypeEnum), n))
                return (TrafficTypeEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Journey_Enum2Str(TrafficTypeEnum type)
        {
            return type.ToString();
        }
        #endregion

        #region 行程计划中的日程类型
                /// <summary>
        /// String型转枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static JourneyTypeEnum Journey_Str2Enum(string name, bool igonreCase)
        {
            if (name == "") return JourneyTypeEnum.无;

            return (JourneyTypeEnum)Enum.Parse(typeof(JourneyTypeEnum), name, igonreCase);
        }
        /// <summary>
        /// 枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int Journey_Enum2Int(JourneyTypeEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static JourneyTypeEnum Journey_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(JourneyTypeEnum), n))
                return (JourneyTypeEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Journey_Enum2Str(JourneyTypeEnum type)
        {
            return type.ToString();
        }
        #endregion

        #region 行程计划中的订票类型
        /// <summary>
        /// String型转枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static TicketTypeEnum Ticket_Str2Enum(string name, bool igonreCase)
        {
            return (TicketTypeEnum)Enum.Parse(typeof(TicketTypeEnum), name, igonreCase);
        }
        /// <summary>
        /// 枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int Ticket_Enum2Int(TicketTypeEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static TicketTypeEnum Ticket_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(TicketTypeEnum), n))
                return (TicketTypeEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Ticket_Enum2Str(TicketTypeEnum type)
        {
            return type.ToString();
        }
        #endregion

        #region 订单状态类型
        /// <summary>
        /// String型转枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static OrderStateEnum OrderState_Str2Enum(string name, bool igonreCase)
        {
            return (OrderStateEnum)Enum.Parse(typeof(OrderStateEnum), name, igonreCase);
        }
        /// <summary>
        /// 枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int OrderState_Enum2Int(OrderStateEnum type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static OrderStateEnum OrderState_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(OrderStateEnum), n))
                return (OrderStateEnum)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string OrderState_Enum2Str(OrderStateEnum type)
        {
            return type.ToString();
        }
        #endregion

        #region 汽车价别类型
        /// <summary>
        /// String型转枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        //public static VehiclePriceType VehiclePriceType_Str2Enum(string name, bool igonreCase)
        //{
        //    return (VehiclePriceType)Enum.Parse(typeof(VehiclePriceType), name, igonreCase);
        //}
        /// <summary>
        /// 枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        //public static int VehiclePriceType_Enum2Int(VehiclePriceType type)
        //{
        //    return (int)type;
        //}
        /// <summary>
        /// Int型转成枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        //public static VehiclePriceType VehiclePriceType_Int2Enum(int n)
        //{
        //    if (Enum.IsDefined(typeof(VehiclePriceType), n))
        //        return (VehiclePriceType)n;
        //    else
        //        throw new Exception(n + "没定义");
        //}
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        //public static string VehiclePriceType_Enum2Str(VehiclePriceType type)
        //{
        //    return type.ToString();
        //}
        #endregion

        #region 汽车路程类型
        /// <summary>
        /// String型转枚举型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="igonreCase"></param>
        /// <returns></returns>
        public static VehicleJourneyType VehicleJourneyType_Str2Enum(string name, bool igonreCase)
        {
            return (VehicleJourneyType)Enum.Parse(typeof(VehicleJourneyType), name, igonreCase);
        }
        /// <summary>
        /// 枚举转成Int型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int VehicleJourneyType_Enum2Int(VehicleJourneyType type)
        {
            return (int)type;
        }
        /// <summary>
        /// Int型转成枚举类型
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static VehicleJourneyType VehicleJourneyType_Int2Enum(int n)
        {
            if (Enum.IsDefined(typeof(VehicleJourneyType), n))
                return (VehicleJourneyType)n;
            else
                throw new Exception(n + "没定义");
        }
        /// <summary>
        /// 交通工具类型枚举转成String型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string VehicleJourneyType_Enum2Str(VehicleJourneyType type)
        {
            return type.ToString();
        }
        #endregion

    }
}
